/*
 * @Author: szx
 * @Date: 2022-02-18 13:32:10
 * @LastEditTime: 2022-02-18 13:35:29
 * @Description:
 * @FilePath: \leetcode\1-99\24\24_2.js
 */
function ListNode(val, next) {
    this.val = val === undefined ? 0 : val;
    this.next = next === undefined ? null : next;
}

/**
 * @param {ListNode} head
 * @return {ListNode}
 */
var swapPairs = function (head) {
    let prev = new ListNode(-1, head);
    let cur = prev;
    while (cur && cur.next) {
        const tmp1 = cur.next;
        cur.next = tmp1.next;
        const tmp2 = cur.next.next;
        cur.next.next = tmp1;
        tmp1.next = tmp2;
        cur = tmp1;
    }
    return prev.next;
};
